import CustomBehavior from '../core/Base/Behavior'
import { ForceMode } from '../core/Base/Physics';
import Vector2 from '../core/Base/Vector2';
import Input from '../core/IO/Input';
import Sprite from '../core/UI/Sprite'
import Time from '../core/Tools/Time'
class Player extends CustomBehavior {
    //  start init
    player: Sprite
    constructor(player: Sprite) {
        super()
        this.player = player;
    }
    start() {

    }
    //  update
    update() {
        const direction = Input.getButtonAxias('horizontal')
        if (direction) {
            this.player.addForce(new Vector2(50 * direction * Time.detalTime, 0), ForceMode.Velocity);
        } else {
            this.player.velocity = new Vector2(0, 0)
        }
    }
}

export default Player